package com.github.eclipseace.mybatis.crud;

/**
 * @author eclipseAce
 * @param <E>
 */
public class Example<E> {
	private final E probe;
	private final MatchMode matchMode;

	private Example(E probe, MatchMode matchMode) {
		this.probe = probe;
		this.matchMode = matchMode;
	}

	public static <E> Example<E> allMatching(E probe) {
		return new Example<E>(probe, MatchMode.ALL);
	}

	public static <E> Example<E> anyMatching(E probe) {
		return new Example<E>(probe, MatchMode.ANY);
	}

	public boolean isAllMatching() {
		return MatchMode.ALL.equals(matchMode);
	}

	public boolean isAnyMatching() {
		return MatchMode.ANY.equals(matchMode);
	}

	public E getProbe() {
		return probe;
	}

	private static enum MatchMode {
		ALL, ANY;
	}
}
